package 剑指Offer专项突破;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author zhang lei
 * @Date 2022-04-20 19:34
 */
public class Algo004 {
    public static int singleNumber(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            map.merge(num, 1, Integer::sum);
        }
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if(entry.getValue() == 1) {
                return entry.getKey();
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println(singleNumber(new int[]{-2,-2,-2,3}));;
    }

}
